//
//  PresentationDismissAnimation.m
//  CKApp
//
//  Created by CC on 2020/9/4.
//  Copyright © 2020 This Moment. All rights reserved.
//

#import "PresentationDismissAnimation.h"
#import "PresentationModalConfig.h"
#import "LcFoundation.h"

@implementation PresentationDismissAnimation

- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext {
  return PRESENTATION_ANIMATE_DURATION;
}

- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
  UIView* fromView = [transitionContext viewForKey:UITransitionContextFromViewKey];
  if (fromView) {
    [UIView animateWithDuration:PRESENTATION_ANIMATE_DURATION delay:PRESENTATION_DELAY options:UIViewAnimationOptionCurveEaseInOut animations:^{
      fromView.transform = CGAffineTransformMakeTranslation(0, LcUIUtility.screenHeight);
      fromView.alpha = 0.0;
    } completion:^(BOOL finished) {
      fromView.transform = CGAffineTransformMakeTranslation(0, 0);
      fromView.alpha = 1.0;
      [transitionContext completeTransition:finished];
    }];
  }
}

@end
